{extend name="admin@public/content"}

{block name="content"}
<form autocomplete="off"  onsubmit="return false;" action="/admin/Config/posteait" data-auto="true" method="post" class='form-horizontal layui-form padding-top-20'>
    {foreach $list['list'] as $k=>$v}
    {if ($v.name eq 'is_referee') OR ($v.name eq 'is_xfjl') OR ($v.name eq 'is_hb') OR ($v.name eq 'is_agent')}

    <div class="form-group">
        <label class="col-sm-2 control-label">
            {$v.description}
        </label>

        <div class="col-sm-8 form-group layui-card layui-form">
            <div class="layui-card-body layui-row layui-col-space10">
                <div class="layui-col-md12">
                    <input type="checkbox" name="{$v.name}" lay-skin="switch" value="{$v.data}" lay-filter="toggle" lay-text="开启|关闭"  <?php if($v['data'] == 1){?> checked <?php }?>>
                </div>
            </div>
        </div>
    </div>
    {else}
    <div class="form-group">
        <label class="col-sm-2 control-label">
            {$v.description}
        </label>
        <div class='col-sm-8'>
            <input name="{$v.name}" required="required" title="请输入程序名称" placeholder="请输入程序名称" value="{$v.data}" class="layui-input">
            <p class="help-block">平台重要数据，请勿轻易修改</p>
        </div>
    </div>
    {/if}
    {/foreach}

    <div class="hr-line-dashed"></div>

    <div class="col-sm-4 col-sm-offset-2">
        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存配置</button>
        </div>
    </div>

</form>
<script>
    layui.use(['layer', 'form'], function(){
        var layer = layui.layer
            ,form = layui.form;
        form.render();

        form.on('switch(toggle)', function(data){
            var name = data.elem.name;
            var value = data.elem.value;
            if(name && value){
                $.ajax({
                    type: 'get',
                    url: '/admin/Config/editData',
                    data: {name:name,value:value},
                    dataType:  'json',
                    success: function(data){
                        layer.msg(data.msg);
                        location.reload();
                    }
                });
            }else{
                layer.msg('参数错误');
            }
        });

    });
</script>

{/block}
